package org.nlp2rdf.navigator.client.common;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@SuppressWarnings("serial")
public class LearnedConceptDTO extends ConceptDTO {

	protected double accuracy = 0.0;
	protected Map<String, String> conceptComments = new HashMap<String, String>();

	private MyExamples examples = new MyExamples();

	/**
	 * Use is discouraged and only for beans and serializers use other
	 * constructor
	 */
	@Deprecated
	@SuppressWarnings("deprecation")
	public LearnedConceptDTO() {
		super();
	}

	@SuppressWarnings("deprecation")
	public LearnedConceptDTO(ConceptDTO conceptDTO, double accuracy, MyExamples examples) {
		super();
		setBase(conceptDTO.base);
		setComment(conceptDTO.comment);
		setKbSyntaxString(conceptDTO.kbSyntaxString);
		setLabel(conceptDTO.label);
		setManchesterSyntaxString(conceptDTO.manchesterSyntaxString);
		setMsNeeded(conceptDTO.msNeeded);
		setNamedConceptsAndProperties(conceptDTO.namedConceptsAndProperties);
		setNamespaceToPrefix(conceptDTO.namespaceToPrefix);
		setPrefixToNamespace(conceptDTO.prefixToNamespace);
		this.accuracy = accuracy;
		this.examples = examples;
	}

	@Override
	public String toString() {
		StringBuffer ret = new StringBuffer();
		ret.append(super.toString());
		ret.append("Acc: " + getAccuracy() + " ");
		return ret.toString();
	}

	/** GETTERS AND SETTER BELOW **/

	public double getAccuracy() {
		return accuracy;
	}

	public void setAccuracy(double accuracy) {
		this.accuracy = accuracy;
	}

	public Map<String, String> getConceptComments() {
		return conceptComments;
	}

	public void setConceptComments(Map<String, String> conceptComments) {
		this.conceptComments = conceptComments;
	}

	public void setExamples(MyExamples examples) {
		this.examples = examples;
	}

	public MyExamples getExamples() {
		return examples;
	}

	public static class MyExamples implements Serializable {

		private List<ExampleDTO> positives = new ArrayList<ExampleDTO>();
		private List<ExampleDTO> negatives = new ArrayList<ExampleDTO>();

		public MyExamples() {
			super();
		}

		public MyExamples(List<ExampleDTO> positives, List<ExampleDTO> negatives) {
			super();
			this.positives = positives;
			this.negatives = negatives;
		}

		@Override
		public String toString() {
			return "pos|neg|total: " + positives.size() + " | " + negatives.size() + " | "
					+ (negatives.size() + positives.size());
		}

		public String toFullString() {
			return "pos|neg|total: " + positives.size() + " | " + negatives.size() + " | "
					+ (negatives.size() + positives.size()) + "\n" + positives + "\n" + negatives + "\n";
		}

		public List<ExampleDTO> getPositives() {
			return positives;
		}

		public void setPositives(List<ExampleDTO> positives) {
			this.positives = positives;
		}

		public List<ExampleDTO> getNegatives() {
			return negatives;
		}

		public void setNegatives(List<ExampleDTO> negatives) {
			this.negatives = negatives;
		}

	}

}
